<div class="dialog-wrap" id="talentDialogContent">
    <form class="layui-form">
        <div class="layui-row">
            <div class="layui-col-md8 layui-col-md-offset2">
                <div class="layui-row">
                    <div class="layui-col-md6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">联系人姓名</label>
                            <div class="layui-input-block">
                                <input type="text" name="contactName"  lay-verify="required" lay-reqtext="联系人姓名不能为空" placeholder="" autocomplete="off" class="layui-input" th:value="${vo.contactName}">
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">手机号</label>
                            <div class="layui-input-block">
                                <input type="text" name="mobile"  lay-verify="required|phone|number" lay-reqtext="手机号不能为空" placeholder="" autocomplete="off" class="layui-input" th:value="${vo.mobile}">
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">邮箱</label>
                            <div class="layui-input-block">
                                <input type="text" name="email"  lay-verify="validateEmail" placeholder=""  autocomplete="off" class="layui-input" th:value="${vo.email}">
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">地址</label>
                            <div class="layui-input-block">
                                <input type="text" name="address"  placeholder="" autocomplete="off" class="layui-input" th:value="${vo.address}">
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">固定电话</label>
                            <div class="layui-input-block">
                                <input type="text" name="telephone"  placeholder="" autocomplete="off" class="layui-input" th:value="${vo.telephone}">
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">QQ</label>
                            <div class="layui-input-block">
                                <input type="text" name="qq"  placeholder="" autocomplete="off" class="layui-input" th:value="${vo.qq}">
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">微信</label>
                            <div class="layui-input-block">
                                <input type="text" name="wechat"  placeholder="" autocomplete="off" class="layui-input" th:value="${vo.wechat}">
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">性别</label>
                            <div class="layui-input-block">
                                <input type="radio" name="sex" value="1" title="男" th:field="${vo.sex}">
                                <input type="radio" name="sex" value="0" title="女" th:field="${vo.sex}">
                            </div>
                        </div>
                    </div>

                    <div class="layui-col-md6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">出生年月</label>
                            <div class="layui-input-block">
                                <input type="text" name="birthday" id="birthday"  th:value="${#dates.format(vo.birthday,'yyyy-MM-dd')}" placeholder=""  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>

                    <!--此处从后台获取-->
           <!--         <div class="layui-col-md6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">联系人状态</label>
                            <div class="layui-input-block">
                                <select name="contactStatus"  lay-verify="required" lay-reqtext="联系人状态不能为空"  lay-search>
                                    <option value="">请选择</option>
                                    <option value="0">HR001</option>
                                    <option value="1" selected="">HR002</option>
                                    <option value="2">HR003</option>
                                    <option value="3">HR004</option>
                                    <option value="4">HR005</option>
                                </select>
                            </div>
                        </div>
                    </div>-->

                    <!--此处从后台获取-->
                    <div class="layui-col-md6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">负责人</label>
                            <div class="layui-input-block">
                                <input type="text" name="ownerBy" placeholder="" th:value="${vo.ownerBy}" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">备注</label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入备注"  class="layui-textarea" th:value="${vo.description}" name="description" ></textarea>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <a class="layui-btn layui-btn-sm layui-btn-normal" lay-submit lay-filter="operationSaveBtn">保存</a>
                            <a class="layui-btn layui-btn-sm layui-btn-normal" lay-submit lay-filter="operationSubmitBtn">提交</a>
                            <button type="reset" class="layui-btn  layui-btn-sm layui-btn-primary">重置</button>
                            <input type="hidden" name="contactsId" id="hiddenVal" value=""><!--编辑时用到-->
                        </div>
                    </div>


                </div>
            </div>
        </div>
    </form>
</div>
<script>
    layui.use(['form', 'table','laydate'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            laydate = layui.laydate,
            $ = layui.$;

        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;

        /**
         * 开始时间
         **/
        laydate.render({
            elem: '#birthday'
        });

        form.verify({
            validateEmail: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(value!="") {
                    if (!/^[a-z0-9._%-]+@([a-z0-9-]+\.)+[a-z]{2,4}$|^1[3|4|5|7|8]\d{9}$/.test(value)) {
                        return '邮箱格式不对';
                    }
                }
            }
        });


        //监听保存
        form.on('submit(operationSaveBtn)', function (data) {
            data.field.id = 2;
            data.field.operation = 1;//保存
            /*var index = layer.alert(JSON.stringify(data.field), {
               title: '最终的提交信息'
            });*/
            _subUrl = '/api/project/edit.json';
            $.ajax({
                url: _subUrl,
                dataType: 'json',
                contentType:"application/json;charset=utf-8",
                type: 'post',
                data: {data:JSON.stringify(data.field)},
                success: function (response) {
                    if (response.code == 200 && res.message == '保存成功') {
                        parent.layer.msg(res.message, {
                            time: 1000, //1s后自动关闭
                        });
                        // 关闭弹出层
                        layer.close(parentIndex);
                    } else {
                        parent.layer.msg(res.message,{
                            time: 1000, //1s后自动关闭
                        });
                        return false;
                    }
                }
            })
        }, function () {
            // 关闭弹出层
            layer.close(parentIndex);

        });



        //监听提交
        form.on('submit(operationSubmitBtn)', function (data) {
            layer.close(parentIndex);
            return false;
            data.field.id = 2;
            data.field.operation = 2;//提交
            /*var index = layer.alert(JSON.stringify(data.field), {
               title: '最终的提交信息'
            });*/
            _subUrl = '/api/project/edit.json';
            $.ajax({
                url: _subUrl,
                dataType: 'json',
                contentType:"application/json;charset=utf-8",
                type: 'post',
                data: {data:JSON.stringify(data.field)},
                success: function (response) {
                    if (response.code == 200 && res.message == '保存成功') {
                        parent.layer.msg(res.message, {
                            time: 1000, //1s后自动关闭
                        });
                        // 关闭弹出层
                        layer.close(parentIndex);
                    } else {
                        parent.layer.msg(res.message,{
                            time: 1000, //1s后自动关闭
                        });
                        return false;
                    }
                }
            })
        }, function () {
            // 关闭弹出层
            layer.close(parentIndex);

        });

        return false;
    });
</script>
</body>
</html>
